import java.util.Scanner;
import java.util.Stack;

public class test3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();
        System.out.println(calculate(str));
    }
    public static int calculate(String s) {
        Stack<Integer> stack = new Stack<>();//用来记录数字
        int i = 0;
        char ch='+';
        while (i<s.length()){
            if(s.charAt(i)==' ') i++;
            else if (s.charAt(i)>='0'&&s.charAt(i)<='9') {
                int tmp =0;
                while (i<s.length()&&s.charAt(i)>='0'&&s.charAt(i)<='9'){
                    tmp = 10*tmp+(s.charAt(i)-'0');
                    i++;
                }
                if (ch=='+') stack.push(tmp);
                else if ((ch=='-')) stack.push(-tmp);
                else if (ch=='*') stack.push(stack.pop()*tmp);
                else if (ch=='/') stack.push(stack.pop()/tmp);
            } else {
                ch = s.charAt(i);
                i++;
            }
        }
        int sum =0;
        while (!stack.empty()){
            sum+=stack.pop();
        }
        return sum;
    }
}
